package com.xxx.corejava.day1125;

public class Hotel {
    private String name;
    private Room[][] rooms;

    public Hotel(String name) {
        this.name = name;
        rooms=new Room[10][12];
        for (int i = 0; i < rooms.length; i++) {
            for (int j = 0; j < rooms[i].length; j++) {
                int roomNoInt=(i+1)*100+(j+1);
                rooms[i][j]=new Room(String.format("%04d",roomNoInt));
            }
            
        }
    }

    public void search(){
        for (int i = 0; i < rooms.length; i++) {
            for (int j = 0; j < rooms[i].length; j++) {
                System.out.print(rooms[i][j].getNo()+"\t");
            }
            System.out.println();
            for (int j = 0; j < rooms[i].length; j++) {
                System.out.print(rooms[i][j]+"\t");
            }
            System.out.println();
            System.out.println();
        }
    }

    public boolean in(String roomNo,Customer customer){
        int roomNoInt=Integer.parseInt(roomNo);
        int i=roomNoInt/100-1;
        int j=roomNoInt%100-1;

        if(rooms[i][j].isState()==true){
            return false;
        }

        rooms[i][j].in(customer);
        return true;
    }

    public boolean out(String roomNo){
        int roomNoInt=Integer.parseInt(roomNo);
        int i=roomNoInt/100-1;
        int j=roomNoInt%100-1;

        if(rooms[i][j].isState()==false){
            return false;
        }

        rooms[i][j].out();
        return true;
    }


















    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
